package com.netistate.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.netistate.dao.UserDao;
import com.netistate.pojo.User;

@Service
@Transactional
public class UserService {
	
	private UserDao userDao;

	/**
	 * 查找用户
	 * @param user
	 * @return
	 */
	public User findUserByUsernameAndPwd(User user) {
		return userDao.findUserByUsernameAndPwd(user);
	}

	/**
	 * 查询所有用户
	 * @return
	 */
	public List<User> findAll() {
		return userDao.findAll();
	}
	
	/**
	 * 保存用户
	 * @param user
	 */
	public void save(User user) {
		userDao.save(user);
	}
	
	/**
	 * 根据UserName来找User
	 * @param projectManager
	 * @return
	 */
	public User findUserByUsername(String manager) {
		return userDao.findUserByUsername(manager);
	}
	
	/**
	 * 删除
	 */
	public void del(int uid) {
		userDao.del(uid);
	}
	
	@Autowired
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public User findUserById(int uid) {
		
		return userDao.findById(uid);
	}

	public void editsave(User u) {
		userDao.save(u);
		
	}
	
}
